package club.smartdot.string;

import java.util.List;

import redis.clients.jedis.Jedis;

public class RedisString {
	public static void main(String[] args) {
		// 创建Jedis对象,连接到Redis,需要提供ip和port
		Jedis jedis  = new Jedis("127.0.0.1", 6379);
		// 添加字符串
		jedis.set("breakfast", "豆浆和包子");
		String mybreak = jedis.get("breakfast");
		System.out.println("我的早餐1:" + mybreak);
		
		// 追加内容
		jedis.append("breakfast", "还有鸡蛋");
		mybreak = jedis.get("breakfast");
		System.out.println("我的早餐2:" + mybreak);
		
		// 一次设置多个key-value
		jedis.mset("lunch", "红烧肉", "dinner", "牛肉面");
		// 获取多个key的value
		List<String> dinners = jedis.mget("lunch", "dinner");
		for (String dinner : dinners) {
			System.out.println("我吃的是" + dinner);
		}
	}
}
